<include file="Public::header" />	
	<div class="main">
		
		<!---------------------------------------- 个人首页 ---------------------------------------->
		<div class="person">
			<div class="P-info clear">
				<h2>{$member_info.nickname}</h2>
                <php> if ($user[mid] != $member_info['mid']) {</php>
				    <span><q class="ico-save2"></q><a href="javascript:void(0)" id="collect" mid="{$other_member}">收藏</a></span>
				    <span><q class="ico-msg"></q><a href="javascript:void(0)" title="站内信" id="sitesms">站内信</a></span>
				<php> } </php>
                <span class="P-tags">
					<em><php>echo ($user['mid'] === $member_info['mid']) ? '拥有的标签:' : 'Ta拥有的标签:' ;</php> 
                        <php>if ($tag !== false) {</php>
                            <volist name="tag" id="vo">
                                <span class="tag_del_show">
                                <a href="{:U('main/search',array('tag'=>$vo['tagname']))}" title="{$vo.tagname}" target="_blank">
                                    {$vo.tagname}
                                </a>
                                <php>if ($user['mid'] === $member_info['mid']){echo '<span class="tag_del" style="color:red; display:none;cursor:pointer" tid="'.$vo['tid'].'">x</span>';}</php>  
                                </span>
                            </volist>
                        <php>} if ($user['mid'] === $member_info['mid']){
                                if ($tag === false){echo "没有标签&nbsp;&nbsp;";}</php>
                             <a href="javascript:void(0)" id="tag_add">添加新标签</a>
                        <php> } else{ </php>
                            这个人很懒,什么都没留下...
                        <php>}</php>
                    </em>
				</span>
			</div>
			<div class="P-info2">
				<span>{$member_info.comment_c}条评论</span>
				<span>搜龄：{$souvo_age}天</span>
				<span>总点击数：{$member_info.click_c}</span>
				<span>被收藏：{$member_info.collect_c}</span>
			</div>
			<div class="P-detail">
				<div class="P-head">
                    <php>$url = 'people/'.$member_info['mid']</php>
					<a href="{:U($url)}"><img src="__APP__/resources/image/u/{$member_info.large_img}" alt="" /></a>
				</div>
				<div>
					<php>if ($member_info['about']) {</php>
                    <p>
						{$member_info.about}
					</p>
                    <php>}</php>
					<h3>我出现在这些地方：<span>点击数</span></h3>
                    <php> if (empty($link)){ 
                        echo ($user['mid'] == $member_info['mid']) ? '<a href="'.U('memcp/linkset').'" title="链接管理" ">链接管理</a>' :'暂时没有资料...';
                    }else{ </php>
                    <ul>
                    <volist name="link" id="vo">
                        <li><q><img src="__APP__/resources/image/linkico/{$vo.ico}"></q><a href="{$vo.url}" title="{$vo.tname}" target="_blank" lid="{$vo.lid}" class='linkclick'>{$vo.url}</a><span>{$vo.clicknum}</span></li>
                    </volist>
                    </ul>
                    <php> } </php>
				</div>
			</div>
			<div class="P-comment clear">
				<h3><q class="ico-cloud"></q>留言(999)</h3>
				<div class="P-commentF">
					<php>if ($user[mid] !== $member_info['mid']) {</php>
                    <div class="P-commentC-Tip">
                        <img class="expression" alt="心情" src="__APP__/resources/image/e160.gif">
                        <span class="text">来到这里，是不是要为主人留点什么咯？</span>
                    </div>
                    <php>}</php>
				</div>
                <div class="P-commentC ">
                    <ul>
                        <volist name="comment" id="vo">
                        <li>
                            <table style="border-bottom:1px dashed #eee; margin:10px 0;" width=100%>
                                <tr>
                                    <td width="75">
                                        <php>$url = 'people/'.$vo['reply_mid']</php>
                                        <a href="{:U($url)}" title="{$vo.nickname}" target="_blank"><img src="__APP__/resources/image/u/{$vo.small_img}" width=75 height=75 /></a>
                                    </td>
                                    <td>
                                        <p class="pt5 pl5 pr5 pb5">
                                            <a href="{:U($url)}" title="{$vo.nickname}" target="_blank">{$vo.nickname}</a>
                                            {$vo.content}
                                        </p>
                                        <p class="pl5 gray">{:date('Y-m-d',$vo['add_time'])}</p>
                                        <php>if(is_array($vo['reply'])){
                                            foreach ($vo['reply'] as $value) {</php>
                                                <php>$url = 'people/'.$value['reply_mid']</php>
                                                <table class="P-commentC-C">
                                                    <tr>
                                                        <td class="P-commentC-C-Author">
                                                            <p class="pt5 pl5 pr5 pb5"><a href="{:U($url)}" title="{$value.nickname}" target="_blank"><img src="__APP__/resources/image/u/{$value.small_img}" width=75 height=75 /></a></p>
                                                        </td>
                                                        <td>
                                                            <p class="pl10 pt10 pr10 pb5 gray"><a href="{:U($url)}" title="{$value.nickname}" target="_blank">{$value.nickname}</a> {:date('Y-m-d',$value['add_time'])} </p>
                                                            <p class="pl10">{$value.content}
                                                            <php>if ($value['reply_mid'] != $user['mid']){</php>
                                                                <a href="javascript:void(0)" title="回复" nickname='{$value.nickname}' class="add_reply">&nbsp;回复</a>
                                                            <php>}</php>
                                                            </p>
                                                        </td>
                                                    </tr>
                                                </table>
                                            <php>}</php>
                                        <php>}</php>
                                        <php>if ($vo['reply_mid'] != $user['mid'] || $value['reply_mid'] != $user['mid']){</php>
                                        <table class="P-commentC-C">
                                            <tr>
                                                <td class="pt5 pl5 pr5 pb5">
                                                    <textarea name="post" style="broder:1px solid #ccc;height:18px;padding:3px;width:482px; color:#999"  class="reply_textarea_s">添加回复</textarea>
                                                    <p><span style="color:#999">0/140</span>
                                                        <input type="button" name="post_reply" class="post_reply" value="回复" />
                                                        <input type="hidden" name="cid" value="{$vo.cid}" />
                                                        <input type="hidden" name="mid" value="{$vo.mid}" />
                                                    </p>
                                                </td>
                                            </tr>
                                        </table>
                                        <php>}</php>
                                    </td>
                                </tr>
                            </table>
                        </li>
                        </volist>
                    </ul>
                    <div class="P-commentF">
                        <textarea></textarea><br/>
                        <input type="button" value="留言" id='post_reply_b'/>
                        <input type="hidden" name="mid" value="{$member_info['mid']}" />
                    </div>
                </div>
			</div>
		</div>
		<!---------------------------------------- 个人首页 End ------------------------------------>
	</div>
	<!-- main End -->
<include file="Public::footer" />
<script type="text/javascript">
$(function(){
    $('#collect').click(function(){
        var err = new Array();
        err[999999999998] = '非法';
        err[999999999999] = '请先登录';
        $.post('{:U('people/collectadd')}',{
            otmid : $(this).attr('mid')
        },
        function(txt){
            if(typeof(err[txt]) != 'undefined'){
                alert(err[txt]);
            }else{
                alert('收藏成功');
                $('.P-info2 span').eq(3).text('被收藏：'+txt);
            }
        },'json' );         
    });

    $('.linkclick').each(function(){
        $(this).click(function(){
            var click_num_node = $(this).next('span');
            $.post('{:U('people/clicknum')}',{
                lid : $(this).attr('lid')
            },function(){
                click_num_node.text(Number(click_num_node.text())+1);
            },'json');
        })        
    })

    $('.reply_textarea_s').each(function(){
        $(this).focus(function(){
            reply($(this));
        }).blur(function(){
            reply($(this));
        })
    })
    $('.add_reply').each(function(){
        $(this).click(function(){
            var nickname = $(this).attr('nickname');
            var area = $(this).parents('li').find('textarea');
            $(area).val('回复'+nickname+'： ').css({color:'#333',height:'30px'}).focus();
        })
    })
    function reply(option){
        if ($(option).val() == '添加回复') {
            $(option).val('').css({color:'#333',height:'30px'})
        }else if ($(option).val() == '') {
            $(option).val('添加回复').css({color:'#999',height:'18px'})
        }
    }
    $('.post_reply').each(function(){
        $(this).click(function(){
            postReply({obj:$(this)});
        });
    })
    $('#post_reply_b').click(function(){
        postReply({ obj:$(this),tp:1 });
    })
    function postReply(opt){
        var obj = opt.obj;
        var tp = opt.tp;
        var err = new Array();
        err[1] = '非法';
        err[2] = '请先登录';
        err[3] = '请填写内容';
        err[4] = '回复内容不能超过140字';
        err[5] = '忙不过来了，您休息会...';
        var cid = obj.next('input[name=cid]').val();
        cid = (cid) ? cid : 0;
        var mid = obj.nextAll('input[name=mid]').val();
        if (tp == 1) {
            var reply_content = obj.parent().find('textarea').val();
        }else{
            var reply_content = obj.parents('li').find('textarea').val();
        }
      
        $.post('{:U('people/replyAdd')}',{
            cid : cid,
            mid : mid,
            reply_content : reply_content
        },function(txt){
            if(typeof(err[txt]) != 'undefined'){
                alert(err[txt]);
            }else{
                obj.parents('li').find('textarea').val('').blur();
                if (tp ==1) {
                    obj.parent().prev().append(txt.msg);
                }else{
                    obj.parents('.P-commentC-C').before(txt.msg);
                }
                
            }
        },'json');
    }
    
    $('#sitesms').click(function(){
        sms_dialog();
    })

    function sms_dialog(){
    <php>if (!$user){</php>
        alert('请先登录');
        return false;
    <php>}</php>
        $.dialog({
            lock:true,
            id : 'sms_dialog',
            width:300,
            height:100,
            content :'<div id="sms"><p id="sms_tip"></p><p><textarea id="sms_content"></textarea></p><p><input type="button" value="发送" id="send_sms" /></p></div>',
            title: '给{$member_info.nickname}发站内信:'
            });
    }

    $('#send_sms').live('click',function(){
        $('#sendsms').attr('disabled',true);
        var content = $('#sms_content').val();
        var receive_id = {$member_info.mid};
        var err = new Array();
        err[1] = '非法';
        err[2] = '站内信内容不能为空';
        err[3] = '请先登录';
        $.post("{:U('people/sendsms')}",{
            receive_id : receive_id,
            content : content
        }, function(txt){
            if(typeof(err[txt]) != 'undefined'){
                alert(err[txt]);
                $('#send_sms').attr('disabled',false);
                art.dialog.get('sms_dialog').close();
            }else{
                alert('发送成功');
                $('#send_sms').attr('disabled',false);
                art.dialog.get('sms_dialog').close();
            }
        },'json' );     
    })
    $('#tag_add').click(function(){
        $.dialog({
            lock:true,
            id : 'tag_dialog',
            width:300,
            height:100,
            content :'<div id="tag"><p><input type="text" name="tagname" id="tagname" /></p><p><input type="button" value="发送" id="tag_add_btn" /></p></div>',
            title: '添加新标签:'
        });
    })
    $('#tag_add_btn').live('click',function(){
        $('#tag_add_btn').attr('disabled',true);
        var tagname = $('#tagname').val();
        var err = new Array();
        err[1] = '非法';
        err[2] = '标签名不能为空';
        err[3] = '请先登录';
        $.post("{:U('people/tagadd')}",{
            tagname : tagname
        }, function(txt){
            if(typeof(err[txt]) != 'undefined'){
                alert(err[txt]);
                $('#tag_add_btn').attr('disabled',false);
            }else{
                alert('添加成功');
                $('#tag_add_btn').attr('disabled',false);
                art.dialog.get('tag_dialog').close();
                $('#tag_add').before(txt.msg);
            }
        },'json' );     
    })

    $('.tag_del_show').live({
        mousemove:function(){
            $(this).children('.tag_del').show();
        },
        mouseout:function(){
            $(this).children('.tag_del').hide();
        }
    });
    $('.tag_del').live('click',function(){
        var obj = $(this);
        var tid = obj.attr('tid');
        var err = new Array();
        err[1] = '非法';
        err[2] = '请先登录';
        $.post("{:U('people/tagdel')}",{
            tid : tid
        }, function(txt){
            if(typeof(err[txt]) != 'undefined'){
                alert(err[txt]);
            }else{
                alert('删除成功');
                obj.parent().remove();
            }
        },'json' );
    })
})    
</script>